package com.xinqi.common.third.onekey;

import com.xinqi.common.third.onekey.client.OneKeyHelp;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 一键登录
 *
 * @author linkai
 * @date 2023/2/18
 */
@Configuration
@ConditionalOnProperty(prefix = "third.one-key", name = {"secretId"})
@EnableConfigurationProperties(value = OneKeyProperties.class)
public class OneKeyConfig {
    @Bean
    public OneKeyHelp oneKeyHelp(OneKeyProperties oneKeyProperties) {
        return OneKeyHelp.create(
            oneKeyProperties.getSecretId(),
            oneKeyProperties.getSecretKey(),
            oneKeyProperties.getBusinessId(),
            oneKeyProperties.getUrl()
        );
    }
}
